﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加角色</title>
     <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../Js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../Js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
    <script src="../Js/json2.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var Row = null;
        var pWind = null;
        $(function () {

            //$selectRow
            pWind = parent.window.parent.window.getWindow();
            Row = { J_ID: 0, A_ID: 0, A_NAME: '', A_LEVEL: 0, R_ID: 0, R_NAME: '', R_POWER: 0, R_REMARK: '' };
            var Tdata = [{ id: 0, text: '普通员'}];
            if (Row != null) {
                //赋值
                $("#txtName").ligerComboBox({ width: 140, slide: false, url: '../WebServer/MainAdmin.ashx?Action=GetTheRoleTableList' });

                $("#txtArea").ligerComboBox({
                    width: 140,
                    selectBoxWidth: 200,
                    selectBoxHeight: 200, valueField: 'id', treeLeafOnly: false, slide: false, initValue: Row.A_ID,
                    tree: { url: '../WebServer/MainAdmin.ashx?Action=AreaTree', checkbox: false }
                });
              

            } //end if row

            //保存
            $("#btnSave").click(function () {
                if (chk()) {
                    if (Row) {

                        Row.R_NAME = $("#txtName").val();
                        Row.R_ID = $("#txtName_val").val();
                       

                        Row.A_NAME = $("#txtArea").val();
                        Row.A_ID = $("#txtArea_val").val();

                        var pars = { data: JSON2.stringify(Row) };
                        $("body").mask("数据处理中，请稍候......");
                        $.post('../WebServer/MainAdmin.ashx?Action=AddRole', pars, function (data) {
                            $("body").unmask();
                            var rdata = eval("(" + data + ")");
                            if (rdata.IsSuccess == 1) {
                                showAlertOk("保存成功");
                                if (pWind) pWind.loadGrid();
                            } else {
                                if (rdata.IsSuccess == -99)
                                    showErrorTip("这个角色在该区域下已经分配过!");
                                else
                                    showErrorTip(rdata.Msg);
                            }
                        });
                    } //end row
                } //end chk
            });
            $("#btnCancel").click(function () { closeRefresh(false, ""); });

        });


        function chk() {
            var err = "";

            if ($.trim($("#txtName").val()) == "") {
                err = "请输入职务名称!";
                showErrorTip(err);
                return false;
            }
            if ($.trim($("#txtArea").val()) == "") {
                err = "请选择区域!";
                showErrorTip(err);
                return false;
            }
           


            return true;
        }
      
    </script>

     <style type="text/css">
        .edittable td.editcellmessage,.edittable td.editcellverify,.edittable td.editcell{ padding:5px;line-height:25px;}
        .edittable td.editcellmessage{ padding-left:20px;} 
        body { font-size:12px; background:white;}
         
    </style>
</head>
<body>
<form id="from1" action="">
     <table cellpadding="0" border="0" cellspacing="0" class="edittable">
        <tr>
         <td  class="editcellmessage">职务名称:</td>
         <td class="editcellmessage"> <input id="txtName" name="txtName" type="text"  /> </td>
        </tr>
       
        <tr>
              <td  class="editcellmessage">区域:</td>
              <td class="editcellmessage"> <input id="txtArea" name="txtArea" type="text"  /> </td>
        </tr>
       
      
   </table>
       <div class="buttonpanel">
             <div style="float:right;margin-right:10px;">
                 <a id="btnSave" class="button" href="javascript:void(0);"><span>保存</span></a>
                 <a id="btnCancel" class="button" href="javascript:void(0);"><span>关闭</span></a>
              </div>
      </div>
   </form>
</body>
</html>